Option Strict On
Option Explicit On 

Imports System
Imports System.Object
Imports System.Collections
Imports System.Collections.Specialized
Imports Microsoft.VisualBasic.ControlChars

'This class implements the FGDC/NBII Contact Information section.

Public Class ContactInfo
    Private m_bConPrimPerson As Boolean = True
    Private m_sConPerson As String = ""
    Private m_sConOrg As String = ""
    Private m_sConPosition As String = ""
    Private m_csConAddress As New StringCollection
    Private m_sConVtel As String = ""
    Private m_sConTDDtel As String = ""
    Private m_sFaxTel As String = ""
    Private m_sConEmail As String = ""
    Private m_sHoursOfService As String = ""
    Private m_sConInstruct As String = ""

    Property PrimaryPerson() As Boolean
        Get
            PrimaryPerson = m_bConPrimPerson
        End Get
        Set(ByVal Value As Boolean)
            m_bConPrimPerson = Value
        End Set
    End Property
    Property Person() As String
        Get
            Person = m_sConPerson
        End Get
        Set(ByVal Value As String)
            m_sConPerson = Value
        End Set
    End Property

    Property Organization() As String
        Get
            Organization = m_sConOrg
        End Get
        Set(ByVal Value As String)
            m_sConOrg = Value
        End Set
    End Property

    Property Position() As String
        Get
            Position = m_sConPosition
        End Get
        Set(ByVal Value As String)
            m_sConPosition = Value
        End Set
    End Property

    ReadOnly Property AddrCount() As Integer
        Get
            AddrCount = m_csConAddress.Count
        End Get
    End Property
    ReadOnly Property AddrFetch(ByVal cIndex As Integer) As String
        Get
            If (cIndex >= 0 And cIndex < m_csConAddress.Count) Then
                Return m_csConAddress(cIndex)
            Else
                MessageBox.Show("Index out of bounds of collection", "Contact Information Address", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Get
    End Property
    Public Sub AddressAdd(ByVal addrLine As String)
        m_csConAddress.Add(addrLine)
    End Sub
    Public Sub AddrRemove(ByVal value As Integer)
        Dim sErrorText As String = "Attempt to remove contact address " & value.ToString & " failed." & CrLf
        If (value < 0) Then
            sErrorText = sErrorText & "Index values must be greater than or equal to zero!"
            MessageBox.Show(sErrorText, "Index outside of lower bound", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        End If
        If (value < m_csConAddress.Count) Then
            m_csConAddress.RemoveAt(value) 'index is zero-based
        Else
            sErrorText = sErrorText & "There are only " & m_csConAddress.Count.ToString & " addresses!"
            MessageBox.Show(sErrorText, "Index value error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub
    Public Sub AddrUpdate(ByVal sAddress As String, ByVal curindex As Integer)
        'updates the address by inserting the new address before its earlier version, then removing the outdated version
        m_csConAddress.Insert(curindex, sAddress)
        m_csConAddress.RemoveAt(curindex + 1)
    End Sub

    Property VoiceTel() As String
        Get
            VoiceTel = m_sConVtel
        End Get
        Set(ByVal Value As String)
            m_sConVtel = Value
        End Set
    End Property
    Property TDDtel() As String
        Get
            TDDtel = m_sConTDDtel
        End Get
        Set(ByVal Value As String)
            m_sConTDDtel = Value
        End Set
    End Property
    Property FaxTel() As String
        Get
            FaxTel = m_sFaxTel
        End Get
        Set(ByVal Value As String)
            m_sFaxTel = Value
        End Set
    End Property
    Property Email() As String
        Get
            Email = m_sConEmail
        End Get
        Set(ByVal Value As String)
            m_sConEmail = Value
        End Set
    End Property
    Property Hours() As String
        Get
            Hours = m_sHoursOfService
        End Get
        Set(ByVal Value As String)
            m_sHoursOfService = Value
        End Set
    End Property
    Property Instructions() As String
        Get
            Instructions = m_sConInstruct
        End Get
        Set(ByVal Value As String)
            m_sConInstruct = Value
        End Set
    End Property

End Class
